<div class="domains view">
	<h2><?php  echo __d('domains','Domain');?>: <?php echo $this->Html->link($domain['Domain']['name'],'http://'.$domain['Domain']['name']); ?></h2>
	<div class="clear"></div>
	<p><?php echo h($domain['Domain']['descriptions']); ?></p>

	<div class="clear"></div>
	
	<?php if(isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'jobs'):?>
	<div class="related">
		<h3><?php echo __d('domains','Jobs');?></h3>

		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','S'); ?></th>
			<th><?php echo __d('domains','P'); ?></th>
			<th><?php echo __d('domains','Zlecajacy'); ?></th>
			<th><?php echo __d('domains','Descriptions'); ?></th>
			<th><?php echo __d('domains','Wykonawcy'); ?></th>
			<th><?php echo __d('domains','Date end'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Job'), array('controller' => 'jobs', 'action' => 'add','d'=>$domain['Domain']['id']));?></th>
		</tr>
		<?php
			if (!empty($jobs) ){
			$i = 0;
			foreach ($jobs as $job): ?>
			<tr onclick="document.location='<?php echo $this->Html->url( array('controller' => 'jobs', 'action' => 'view', $job['id'],'d'=>$domain['Domain']['id']),true);?>'">
				<td><?php echo $job['id'];?></td>
				<td><?php echo $job['status'];?></td>
				<td><?php echo $job['priorytet'];?></td>
				<td><?php echo $job['zlecajacy'];?></td>
				<td><?php echo $job['description'];?></td>
				<td>
				<?php 
					if(is_array($job['wykonawcy']) && !empty($job['wykonawcy'])){
						foreach ($job['wykonawcy'] as $key => $u) {
							echo $u['username']."<br/>";
						}
					}else{
						echo $job['group'];
					}
				?>&nbsp;</td>
				<td><?php echo h($job['date_end']); ?>&nbsp;</td>
				<td class="actions">
					<?php 
					echo $this->Html->link(__d('domains','View'), array('controller' => 'jobs', 'action' => 'view', $job['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
					echo $this->Html->link(__d('domains','Edit'), array('controller' => 'jobs', 'action' => 'edit', $job['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-inner'));
					echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'jobs', 'action' => 'delete', $job['id'],'d'=>$domain['Domain']['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $job['id'])); ?>
				</td>
			</tr>
		<?php endforeach; } ?>
		</table>	
	</div>
	<?php endif; ?>
	
	
	<?php if(isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'lastminute'):?>
	<div class="related">
		<h3><?php echo __d('domains','Tradedubler');?></h3>

		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Source name'); ?></th>
			<th><?php echo __d('domains','Xml file path'); ?></th>
			<th><?php echo __d('domains','Modified'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New source'), array('controller' => 'sources', 'action' => 'add','d'=>$domain['Domain']['id']));?></th>
		</tr>
		<?php
			if (!empty($sources) ){
			$i = 0;
			foreach ($sources as $source): ?>
			<tr onclick="document.location='<?php echo $this->Html->url( array('controller' => 'sources', 'action' => 'view', $source['Source']['id'],'d'=>$domain['Domain']['id']),true);?>'">
				<td><?php echo $source['Source']['id'];?></td>
				<td><?php echo $source['Source']['name'];?></td>
				<td><?php echo $source['Source']['xml'];?></td>
				<td><?php echo $source['Source']['modified'];?></td>
				<td class="actions">
					<?php					
					echo $this->Html->link(__d('domains','Edit'), array('controller' => 'sources', 'action' => 'edit', $source['Source']['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
					echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'jobs', 'action' => 'delete', $source['Source']['id'],'d'=>$domain['Domain']['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $source['Source']['id'])); ?>
				</td>
			</tr>
		<?php endforeach; } ?>
		</table>	
	</div>
	<?php endif; ?>
		
	
	<?php if (!empty($domain['Configuration']) || isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'settings'):?>	
	<div class="related">		
		<h3><?php echo __d('domains','Settings');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Group'); ?></th>			
			<th><?php echo __d('domains','Name'); ?></th>
			<th class="actions">
				<?php echo $this->Html->link(__d('domains','Update settings'), array('controller' => 'configurations', 'action' => 'install','d'=>$domain['Domain']['id']));?> 
			</th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Configuration'] as $configuration): ?>
			<tr onclick="document.location='<?php echo $this->Html->url(array('controller' => 'configurations', 'action' => 'edit', $configuration['Configuration']['id'],'d'=>$domain['Domain']['id']),true);?>'">
				<td><?php echo $configuration['Configuration']['id'];?></td>
				<td><?php echo $setting_groups[$configuration['Configuration']['cfg_group_id']];?></td>
				<td><?php echo $configuration['Configuration']['name'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'configurations', 'action' => 'edit', $configuration['Configuration']['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
						echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'configurations', 'action' => 'delete', $configuration['Configuration']['id'],'d'=>$domain['Domain']['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $configuration['Configuration']['id'])); ?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>
	
	<?php if (!empty($domain['Article']) || isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'articles'):?>
	<div class="related">		
		<h3><?php echo __d('domains','Related Articles');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Title'); ?></th>
			<th><?php echo __d('domains','Description'); ?></th>
			<th><?php echo __d('domains','Menu'); ?></th>
			<th><?php echo __d('domains','Status'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Article'), array('controller' => 'articles', 'action' => 'add','d'=>$domain['Domain']['id']));?> </th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Article'] as $article): 
			$article = $article['Article'];
			?>
			<?php if(isset($this->passedArgs['t']) && $this->passedArgs['t'] == 'addpost'){?>
			<tr onclick="document.location='<?php echo $this->Html->url(  array('controller'=>'posts','action' => 'add','a'=>$article['id'],'d'=>$domain['Domain']['id']),true);?>'">
			<?php }else{?>
			<tr>
			<?php }?>
				<?php  $onclick = "onclick=\"document.location='{$this->Html->url(  array('controller' => 'articles', 'action' => 'view', $article['id'],'d'=>$domain['Domain']['id']),true)}'\"";?>
				<td <?php echo $onclick?>><?php echo $article['id'];?></td>
				<td <?php echo $onclick?>><?php echo $article['name'];?></td>
				<td <?php echo $onclick?>><?php echo h($article['descriptions']);?></td>
				<td><?php echo $this->Form->input('Article.menuses_id',array('options'=>$menuses_combobox,'selected'=>$article['menuses_id'],'label'=>false, 'empty'=>'','style'=>'width: 95%;'));?></td>
				<td><?php echo $this->Form->input('Article.status',array('value'=>$article['status'],'label'=>false,'type'=>'checkbox','checked'=>$article['status'],'disabled'=>true));?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','+ Post'), array('controller'=>'posts','action' => 'add','a'=>$article['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'articles', 'action' => 'edit', $article['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-right'));
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>
	
	<?php if (!empty($domain['Comment']) || isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'comments'):?>
	<div class="related">
		<h3><?php echo __d('domains','Comments');?></h3>	
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Title'); ?></th>
			<th><?php echo __d('domains','Content'); ?></th>
			<th><?php echo __d('domains','Status'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Comment'), array('controller' => 'comments', 'action' => 'add','d'=>$domain['Domain']['id']));?></th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Comment'] as $comment): ?>
			<tr onclick="document.location='<?php echo $this->Html->url(array('controller' => 'comments', 'action' => 'edit', $comment['id']),true);?>'">
				<td><?php echo $comment['id'];?></td>
				<td><?php echo $comment['title'];?></td>
				<td><?php echo $comment['content'];?></td>
				<td><?php echo $comment['status'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'comments', 'action' => 'edit', $comment['id'],'d'=>$domain['Domain']['id']));					 
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>	
	<?php endif; ?>
	
	

	
	<?php if (!empty($domain['Post']) || isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'posts'):?>
	<div class="related">
		<h3><?php echo __d('domains','Posts');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','User Id'); ?></th>
			<th><?php echo __d('domains','Name'); ?></th>
			<th><?php echo __d('domains','Status'); ?></th>
			<th><?php echo __d('domains','Modified'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Post'), array('controller' => 'posts', 'action' => 'add','d'=>$domain['Domain']['id'],'t'=>'addpost'));?></th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Post'] as $post): ?>
			<tr onclick="document.location='<?php echo $this->Html->url(array('controller' => 'posts', 'action' => 'view', $post['id']),true);?>'">
				<td><?php echo $post['id'];?></td>
				<td><?php echo $post['user_id'];?></td>
				<td><?php echo $post['name'];?></td>
				<td><?php echo $post['status'];?></td>
				<td><?php echo $post['modified'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'posts', 'action' => 'edit', $post['id']));						 
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>
	
	<?php if (!empty($domain['Statistic']) || isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'statistics' ):?>
	<div class="related">
		<h3><?php echo __d('domains','Statistics');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Domain Id'); ?></th>
			<th><?php echo __d('domains','Keyword Id'); ?></th>
			<th><?php echo __d('domains','Pagerank'); ?></th>
			<th><?php echo __d('domains','Position'); ?></th>
			<th><?php echo __d('domains','Backlinks'); ?></th>
			<th><?php echo __d('domains','Created'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Statistic'), array('controller' => 'statistics', 'action' => 'add'));?> </th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Statistic'] as $statistic): ?>
			<tr>
				<td><?php echo $statistic['id'];?></td>
				<td><?php echo $statistic['domain_id'];?></td>
				<td><?php echo $statistic['keyword_id'];?></td>
				<td><?php echo $statistic['pagerank'];?></td>
				<td><?php echo $statistic['position'];?></td>
				<td><?php echo $statistic['backlinks'];?></td>
				<td><?php echo $statistic['created'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','View'), array('controller' => 'statistics', 'action' => 'view', $statistic['id']),array('class'=>'action-left'));
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'statistics', 'action' => 'edit', $statistic['id']),array('class'=>'action-inner'));
						echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'statistics', 'action' => 'delete', $statistic['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $statistic['id'])); 
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>

	</div>
	<?php endif; ?>
	

	<?php if (isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'menus'):?>
	<div class="related">
		<h3><?php echo __d('domains','Menu');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Position'); ?></th>
			<th><?php echo __d('domains','Name'); ?></th>
			<th><?php echo __d('domains','Article'); ?></th>
			<th><?php echo __d('domains','Status'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Menus'), array('controller' => 'menuses', 'action' => 'add','d'=>$domain['Domain']['id']));?></th>
		</tr>
		<?php if (!empty($menuses)):?>
		<?php
			$i = 0;
			foreach ($menuses as $menus): ?>
			<tr>
				<td onclick="document.location='<?php echo $this->Html->url(array('controller' => 'menuses', 'action' => 'edit', $menus['id'],'d'=>$domain['Domain']['id']),true);?>'"><?php echo $menus['id'];?></td>
				<td onclick="document.location='<?php echo $this->Html->url(array('controller' => 'menuses', 'action' => 'edit', $menus['id'],'d'=>$domain['Domain']['id']),true);?>'"><?php $p = (is_null($menus['position']) || $menus['position'] == 0 ) ? 0 :$menus['position'];  echo  $menu_positions[$p];?></td>
				<td onclick="document.location='<?php echo $this->Html->url(array('controller' => 'menuses', 'action' => 'edit', $menus['id'],'d'=>$domain['Domain']['id']),true);?>'"><?php echo $menus['name'];?></td>				
				<td onclick="document.location='<?php echo $this->Html->url(array('controller' => 'menuses', 'action' => 'edit', $menus['id'],'d'=>$domain['Domain']['id']),true);?>'">
				<?php 
					$total = count($menus['article']);
					$i = 0;
					if(is_array($menus['article'])){
					foreach ( $menus['article'] as $key => $a) {
						echo ($i>=1) ? '<br/>' : '';
						echo $this->Html->link($a['name'],array('controller'=>'articles','action'=>'edit',$a['id'],'d'=>$domain['Domain']['id']));
						$i++;
				}}?>
				&nbsp;</td>
				<td><?php echo $this->Form->input('Menus.status',array('value'=>$menus['status'],'label'=>false,'type'=>'checkbox','checked'=>$menus['status']));?></td>
				<td class="actions">
					<?php 
						echo $this->Form->postLink(__d('domains','Up'), array('controller' => 'menuses','action' => 'up', $menus['id'],1,'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
						echo $this->Form->postLink(__d('domains','Down'), array('controller' => 'menuses','action' => 'down', $menus['id'],1,'d'=>$domain['Domain']['id']),array('class'=>'action-inner'));
						echo $this->Html->link(__d('domains','Add'), array('controller' => 'menuses', 'action' => 'add','d'=>$domain['Domain']['id'],'pi'=>$menus['id']),array('class'=>'action-inner'));
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'menuses', 'action' => 'edit', $menus['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-inner'));
						echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'menuses', 'action' => 'delete', $menus['id'],'d'=>$domain['Domain']['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $menus['id']));
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		<?php endif; ?>
		</table>
	</div>
	<?php endif; ?>
	
	
	<?php if (!empty($domain['Project']) && isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'projects'):?>
	<div class="related">
		<h3><?php echo __d('domains','Projects');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Domain'); ?></th>
			<th><?php echo __d('domains','Name'); ?></th>
			<th><?php echo __d('domains','Descriptions'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New Project'), array('controller' => 'projects', 'action' => 'add'));?></th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Project'] as $project): ?>
			<tr onclick="document.location='<?php echo $this->Html->url(array('controller' => 'projects', 'action' => 'view', $project['id']),true);?>'">
				<td><?php echo $project['id'];?></td>
				<td><?php echo $project['domain'];?></td>
				<td><?php echo $project['name'];?></td>
				<td><?php echo $project['descriptions'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','View'), array('controller' => 'projects', 'action' => 'view', $project['id']),array('class'=>'action-left'));
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'projects', 'action' => 'edit', $project['id']),array('class'=>'action-inner'));
						echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'projects', 'action' => 'delete', $project['id']), array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $project['id'])); 
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>
	
	<?php if (isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'authorization'):?>
	<div class="related">
		<h3><?php echo __d('domains','Authorization');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Type'); ?></th>
			<th><?php echo __d('domains','Url'); ?></th>
			<th><?php echo __d('domains','Description'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New authorization'), array('controller' => 'authorizations', 'action' => 'add','d'=>$domain['Domain']['id']));?></th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['Authorization'] as $authorization): ?>
			<tr onclick="document.location='<?php echo $this->Html->url(array('controller' => 'authorizations', 'action' => 'view', $authorization['id'],'d'=>$domain['Domain']['id']),true);?>'">
				<td><?php echo $authorization['id'];?></td>
				<td><?php
					$g = Configure::read('Config.auth_groups'); 
					echo	$g[$authorization['auth_type_id']]; ?>&nbsp;</td>
				<td><?php echo $authorization['web_url'];?></td>
				<td><?php echo $authorization['description'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','View'), array('controller' => 'authorizations', 'action' => 'view', $authorization['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-left'));
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'authorizations', 'action' => 'edit', $authorization['id'],'d'=>$domain['Domain']['id']),array('class'=>'action-inner'));
						echo $this->Form->postLink(__d('domains','Delete'), array('controller' => 'authorizations', 'action' => 'delete', $authorization['id'],'d'=>$domain['Domain']['id']),  array('style'=>'margin-right: 5px;','class'=>'action-right'), __d('domains','Are you sure you want to delete # %s?', $authorization['id'])); 
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>
	
	
	<?php if (!empty($domain['User']) && isset($this->passedArgs['d']) && $this->passedArgs['d'] == 'users'):?>
	<div class="related">
		<h3><?php echo __d('domains','Users');?></h3>
		<table cellpadding = "0" cellspacing = "0">
		<tr>
			<th><?php echo __d('domains','Id'); ?></th>
			<th><?php echo __d('domains','Username'); ?></th>
			
			<th><?php echo __d('domains','Email'); ?></th>
			<th><?php echo __d('domains','First Name'); ?></th>
			<th><?php echo __d('domains','Last Name'); ?></th>
			<th><?php echo __d('domains','Group Id'); ?></th>
			<th class="actions"><?php echo $this->Html->link(__d('domains','New User'), array('controller' => 'users', 'action' => 'add'));?></th>
		</tr>
		<?php
			$i = 0;
			foreach ($domain['User'] as $user): ?>
			<tr onclick="document.location='<?php echo $this->Html->url( array('controller' => 'users', 'action' => 'view', $user['id']),true);?>'">
				<td><?php echo $user['id'];?></td>
				<td><?php echo $user['username'];?></td>
				
				<td><?php echo $user['email'];?></td>
				<td><?php echo $user['first_name'];?></td>
				<td><?php echo $user['last_name'];?></td>
				<td><?php echo $user['group_id'];?></td>
				<td class="actions">
					<?php 
						echo $this->Html->link(__d('domains','Edit'), array('controller' => 'users', 'action' => 'edit', $user['id']));
					?>
				</td>
			</tr>
		<?php endforeach; ?>
		</table>
	</div>
	<?php endif; ?>


</div>
<?php echo $this->element('/menu/left')?>